\(\int \frac {\cot ^2(c+d x) (a B+b B \tan (c+d x))}{(a+b \tan (c+d x))^2} \, dx\) [312]

   Optimal result
   Rubi [A] (verified)
   Mathematica [C] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [C] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 34, antiderivative size = 85 \[ \int \frac {\cot ^2(c+d x) (a B+b B \tan (c+d x))}{(a+b \tan (c+d x))^2} \, dx=-\frac {a B x}{a^2+b^2}-\frac {B \cot (c+d x)}{a d}-\frac {b B \log (\sin (c+d x))}{a^2 d}+\frac {b^3 B \log (a \cos (c+d x)+b \sin (c+d x))}{a^2 \left (a^2+b^2\right ) d} \]

[Out]

-a*B*x/(a^2+b^2)-B*cot(d*x+c)/a/d-b*B*ln(sin(d*x+c))/a^2/d+b^3*B*ln(a*cos(d*x+c)+b*sin(d*x+c))/a^2/(a^2+b^2)/d

Rubi [A] (verified)

Time = 0.22 (sec) , antiderivative size = 85, normalized size of antiderivative = 1.00, number of steps used = 5, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.147, Rules used = {21, 3650, 3732, 3611, 3556} \[ \int \frac {\cot ^2(c+d x) (a B+b B \tan (c+d x))}{(a+b \tan (c+d x))^2} \, dx=-\frac {a B x}{a^2+b^2}+\frac {b^3 B \log (a \cos (c+d x)+b \sin (c+d x))}{a^2 d \left (a^2+b^2\right )}-\frac {b B \log (\sin (c+d x))}{a^2 d}-\frac {B \cot (c+d x)}{a d} \]

[In]

Int[(Cot[c + d*x]^2*(a*B + b*B*Tan[c + d*x]))/(a + b*Tan[c + d*x])^2,x]

[Out]

-((a*B*x)/(a^2 + b^2)) - (B*Cot[c + d*x])/(a*d) - (b*B*Log[Sin[c + d*x]])/(a^2*d) + (b^3*B*Log[a*Cos[c + d*x]
+ b*Sin[c + d*x]])/(a^2*(a^2 + b^2)*d)

Rule 21

Int[(u_.)*((a_) + (b_.)*(v_))^(m_.)*((c_) + (d_.)*(v_))^(n_.), x_Symbol] :> Dist[(b/d)^m, Int[u*(c + d*v)^(m +
 n), x], x] /; FreeQ[{a, b, c, d, n}, x] && EqQ[b*c - a*d, 0] && IntegerQ[m] && ( !IntegerQ[n] || SimplerQ[c +
 d*x, a + b*x])

Rule 3556

Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d*x], x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3611

Int[((c_) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(c/(b*f))
*Log[RemoveContent[a*Cos[e + f*x] + b*Sin[e + f*x], x]], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d,
0] && NeQ[a^2 + b^2, 0] && EqQ[a*c + b*d, 0]

Rule 3650

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Si
mp[b^2*(a + b*Tan[e + f*x])^(m + 1)*((c + d*Tan[e + f*x])^(n + 1)/(f*(m + 1)*(a^2 + b^2)*(b*c - a*d))), x] + D
ist[1/((m + 1)*(a^2 + b^2)*(b*c - a*d)), Int[(a + b*Tan[e + f*x])^(m + 1)*(c + d*Tan[e + f*x])^n*Simp[a*(b*c -
 a*d)*(m + 1) - b^2*d*(m + n + 2) - b*(b*c - a*d)*(m + 1)*Tan[e + f*x] - b^2*d*(m + n + 2)*Tan[e + f*x]^2, x],
 x], x] /; FreeQ[{a, b, c, d, e, f, n}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && NeQ[c^2 + d^2, 0] && I
ntegerQ[2*m] && LtQ[m, -1] && (LtQ[n, 0] || IntegerQ[m]) &&  !(ILtQ[n, -1] && ( !IntegerQ[m] || (EqQ[c, 0] &&
NeQ[a, 0])))

Rule 3732

Int[((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2)/(((a_) + (b_.)*tan[(e_.) + (f_.)
*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])), x_Symbol] :> Simp[(a*(A*c - c*C + B*d) + b*(B*c - A*d + C*d)
)*(x/((a^2 + b^2)*(c^2 + d^2))), x] + (Dist[(A*b^2 - a*b*B + a^2*C)/((b*c - a*d)*(a^2 + b^2)), Int[(b - a*Tan[
e + f*x])/(a + b*Tan[e + f*x]), x], x] - Dist[(c^2*C - B*c*d + A*d^2)/((b*c - a*d)*(c^2 + d^2)), Int[(d - c*Ta
n[e + f*x])/(c + d*Tan[e + f*x]), x], x]) /; FreeQ[{a, b, c, d, e, f, A, B, C}, x] && NeQ[b*c - a*d, 0] && NeQ
[a^2 + b^2, 0] && NeQ[c^2 + d^2, 0]

Rubi steps \begin{align*} \text {integral}& = B \int \frac {\cot ^2(c+d x)}{a+b \tan (c+d x)} \, dx \\ & = -\frac {B \cot (c+d x)}{a d}-\frac {B \int \frac {\cot (c+d x) \left (b+a \tan (c+d x)+b \tan ^2(c+d x)\right )}{a+b \tan (c+d x)} \, dx}{a} \\ & = -\frac {a B x}{a^2+b^2}-\frac {B \cot (c+d x)}{a d}-\frac {(b B) \int \cot (c+d x) \, dx}{a^2}+\frac {\left (b^3 B\right ) \int \frac {b-a \tan (c+d x)}{a+b \tan (c+d x)} \, dx}{a^2 \left (a^2+b^2\right )} \\ & = -\frac {a B x}{a^2+b^2}-\frac {B \cot (c+d x)}{a d}-\frac {b B \log (\sin (c+d x))}{a^2 d}+\frac {b^3 B \log (a \cos (c+d x)+b \sin (c+d x))}{a^2 \left (a^2+b^2\right ) d} \\ \end{align*}

Mathematica [C] (verified)

Result contains complex when optimal does not.

Time = 0.40 (sec) , antiderivative size = 97, normalized size of antiderivative = 1.14 \[ \int \frac {\cot ^2(c+d x) (a B+b B \tan (c+d x))}{(a+b \tan (c+d x))^2} \, dx=-\frac {B \left (\frac {\cot (c+d x)}{a}-\frac {\log (i-\cot (c+d x))}{2 (i a+b)}+\frac {\log (i+\cot (c+d x))}{2 (i a-b)}-\frac {b^3 \log (b+a \cot (c+d x))}{a^2 \left (a^2+b^2\right )}\right )}{d} \]

[In]

Integrate[(Cot[c + d*x]^2*(a*B + b*B*Tan[c + d*x]))/(a + b*Tan[c + d*x])^2,x]

[Out]

-((B*(Cot[c + d*x]/a - Log[I - Cot[c + d*x]]/(2*(I*a + b)) + Log[I + Cot[c + d*x]]/(2*(I*a - b)) - (b^3*Log[b
+ a*Cot[c + d*x]])/(a^2*(a^2 + b^2))))/d)

Maple [A] (verified)

Time = 0.24 (sec) , antiderivative size = 95, normalized size of antiderivative = 1.12

method result size
derivativedivides \(\frac {B \left (-\frac {1}{a \tan \left (d x +c \right )}-\frac {b \ln \left (\tan \left (d x +c \right )\right )}{a^{2}}+\frac {\frac {b \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}-a \arctan \left (\tan \left (d x +c \right )\right )}{a^{2}+b^{2}}+\frac {b^{3} \ln \left (a +b \tan \left (d x +c \right )\right )}{a^{2} \left (a^{2}+b^{2}\right )}\right )}{d}\) \(95\)
default \(\frac {B \left (-\frac {1}{a \tan \left (d x +c \right )}-\frac {b \ln \left (\tan \left (d x +c \right )\right )}{a^{2}}+\frac {\frac {b \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2}-a \arctan \left (\tan \left (d x +c \right )\right )}{a^{2}+b^{2}}+\frac {b^{3} \ln \left (a +b \tan \left (d x +c \right )\right )}{a^{2} \left (a^{2}+b^{2}\right )}\right )}{d}\) \(95\)
parallelrisch \(-\frac {\left (x \,a^{3} d +\ln \left (\tan \left (d x +c \right )\right ) a^{2} b +\ln \left (\tan \left (d x +c \right )\right ) b^{3}-\frac {b \ln \left (\sec ^{2}\left (d x +c \right )\right ) a^{2}}{2}-b^{3} \ln \left (a +b \tan \left (d x +c \right )\right )+a^{3} \cot \left (d x +c \right )+a \,b^{2} \cot \left (d x +c \right )\right ) B}{a^{2} d \left (a^{2}+b^{2}\right )}\) \(101\)
norman \(\frac {\frac {B \,b^{2} \left (\tan ^{2}\left (d x +c \right )\right )}{d \,a^{2}}-\frac {B}{d}-\frac {B \,a^{2} x \tan \left (d x +c \right )}{a^{2}+b^{2}}-\frac {b B a x \left (\tan ^{2}\left (d x +c \right )\right )}{a^{2}+b^{2}}}{\tan \left (d x +c \right ) \left (a +b \tan \left (d x +c \right )\right )}+\frac {B \,b^{3} \ln \left (a +b \tan \left (d x +c \right )\right )}{\left (a^{2}+b^{2}\right ) a^{2} d}-\frac {B b \ln \left (\tan \left (d x +c \right )\right )}{a^{2} d}+\frac {B b \ln \left (1+\tan ^{2}\left (d x +c \right )\right )}{2 d \left (a^{2}+b^{2}\right )}\) \(169\)
risch \(\frac {x B}{i b -a}+\frac {2 i B b x}{a^{2}}+\frac {2 i B b c}{a^{2} d}-\frac {2 i b^{3} B x}{a^{2} \left (a^{2}+b^{2}\right )}-\frac {2 i b^{3} B c}{a^{2} d \left (a^{2}+b^{2}\right )}-\frac {2 i B}{d a \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right )}-\frac {\ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right ) B b}{a^{2} d}+\frac {b^{3} \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-\frac {i b +a}{i b -a}\right ) B}{a^{2} d \left (a^{2}+b^{2}\right )}\) \(173\)

[In]

int(cot(d*x+c)^2*(B*a+b*B*tan(d*x+c))/(a+b*tan(d*x+c))^2,x,method=_RETURNVERBOSE)

[Out]

1/d*B*(-1/a/tan(d*x+c)-b/a^2*ln(tan(d*x+c))+1/(a^2+b^2)*(1/2*b*ln(1+tan(d*x+c)^2)-a*arctan(tan(d*x+c)))+b^3/a^
2/(a^2+b^2)*ln(a+b*tan(d*x+c)))

Fricas [A] (verification not implemented)

none

Time = 0.27 (sec) , antiderivative size = 147, normalized size of antiderivative = 1.73 \[ \int \frac {\cot ^2(c+d x) (a B+b B \tan (c+d x))}{(a+b \tan (c+d x))^2} \, dx=-\frac {2 \, B a^{3} d x \tan \left (d x + c\right ) - B b^{3} \log \left (\frac {b^{2} \tan \left (d x + c\right )^{2} + 2 \, a b \tan \left (d x + c\right ) + a^{2}}{\tan \left (d x + c\right )^{2} + 1}\right ) \tan \left (d x + c\right ) + 2 \, B a^{3} + 2 \, B a b^{2} + {\left (B a^{2} b + B b^{3}\right )} \log \left (\frac {\tan \left (d x + c\right )^{2}}{\tan \left (d x + c\right )^{2} + 1}\right ) \tan \left (d x + c\right )}{2 \, {\left (a^{4} + a^{2} b^{2}\right )} d \tan \left (d x + c\right )} \]

[In]

integrate(cot(d*x+c)^2*(B*a+b*B*tan(d*x+c))/(a+b*tan(d*x+c))^2,x, algorithm="fricas")

[Out]

-1/2*(2*B*a^3*d*x*tan(d*x + c) - B*b^3*log((b^2*tan(d*x + c)^2 + 2*a*b*tan(d*x + c) + a^2)/(tan(d*x + c)^2 + 1
))*tan(d*x + c) + 2*B*a^3 + 2*B*a*b^2 + (B*a^2*b + B*b^3)*log(tan(d*x + c)^2/(tan(d*x + c)^2 + 1))*tan(d*x + c
))/((a^4 + a^2*b^2)*d*tan(d*x + c))

Sympy [C] (verification not implemented)

Result contains complex when optimal does not.

Time = 2.65 (sec) , antiderivative size = 1137, normalized size of antiderivative = 13.38 \[ \int \frac {\cot ^2(c+d x) (a B+b B \tan (c+d x))}{(a+b \tan (c+d x))^2} \, dx=\text {Too large to display} \]

[In]

integrate(cot(d*x+c)**2*(B*a+b*B*tan(d*x+c))/(a+b*tan(d*x+c))**2,x)

[Out]

Piecewise((zoo*B*x, Eq(a, 0) & Eq(b, 0) & Eq(c, 0) & Eq(d, 0)), (B*(-x - cot(c + d*x)/d)/a, Eq(b, 0)), (B*(log
(tan(c + d*x)**2 + 1)/(2*d) - log(tan(c + d*x))/d - 1/(2*d*tan(c + d*x)**2))/b, Eq(a, 0)), (-3*B*d*x*tan(c + d
*x)**2/(2*a*d*tan(c + d*x)**2 + 2*I*a*d*tan(c + d*x)) - 3*I*B*d*x*tan(c + d*x)/(2*a*d*tan(c + d*x)**2 + 2*I*a*
d*tan(c + d*x)) - I*B*log(tan(c + d*x)**2 + 1)*tan(c + d*x)**2/(2*a*d*tan(c + d*x)**2 + 2*I*a*d*tan(c + d*x))
+ B*log(tan(c + d*x)**2 + 1)*tan(c + d*x)/(2*a*d*tan(c + d*x)**2 + 2*I*a*d*tan(c + d*x)) + 2*I*B*log(tan(c + d
*x))*tan(c + d*x)**2/(2*a*d*tan(c + d*x)**2 + 2*I*a*d*tan(c + d*x)) - 2*B*log(tan(c + d*x))*tan(c + d*x)/(2*a*
d*tan(c + d*x)**2 + 2*I*a*d*tan(c + d*x)) - 3*B*tan(c + d*x)/(2*a*d*tan(c + d*x)**2 + 2*I*a*d*tan(c + d*x)) -
2*I*B/(2*a*d*tan(c + d*x)**2 + 2*I*a*d*tan(c + d*x)), Eq(b, -I*a)), (-3*B*d*x*tan(c + d*x)**2/(2*a*d*tan(c + d
*x)**2 - 2*I*a*d*tan(c + d*x)) + 3*I*B*d*x*tan(c + d*x)/(2*a*d*tan(c + d*x)**2 - 2*I*a*d*tan(c + d*x)) + I*B*l
og(tan(c + d*x)**2 + 1)*tan(c + d*x)**2/(2*a*d*tan(c + d*x)**2 - 2*I*a*d*tan(c + d*x)) + B*log(tan(c + d*x)**2
 + 1)*tan(c + d*x)/(2*a*d*tan(c + d*x)**2 - 2*I*a*d*tan(c + d*x)) - 2*I*B*log(tan(c + d*x))*tan(c + d*x)**2/(2
*a*d*tan(c + d*x)**2 - 2*I*a*d*tan(c + d*x)) - 2*B*log(tan(c + d*x))*tan(c + d*x)/(2*a*d*tan(c + d*x)**2 - 2*I
*a*d*tan(c + d*x)) - 3*B*tan(c + d*x)/(2*a*d*tan(c + d*x)**2 - 2*I*a*d*tan(c + d*x)) + 2*I*B/(2*a*d*tan(c + d*
x)**2 - 2*I*a*d*tan(c + d*x)), Eq(b, I*a)), (zoo*B*x/a, Eq(c, -d*x)), (x*(B*a + B*b*tan(c))*cot(c)**2/(a + b*t
an(c))**2, Eq(d, 0)), (-2*B*a**3*d*x*tan(c + d*x)/(2*a**4*d*tan(c + d*x) + 2*a**2*b**2*d*tan(c + d*x)) - 2*B*a
**3/(2*a**4*d*tan(c + d*x) + 2*a**2*b**2*d*tan(c + d*x)) + B*a**2*b*log(tan(c + d*x)**2 + 1)*tan(c + d*x)/(2*a
**4*d*tan(c + d*x) + 2*a**2*b**2*d*tan(c + d*x)) - 2*B*a**2*b*log(tan(c + d*x))*tan(c + d*x)/(2*a**4*d*tan(c +
 d*x) + 2*a**2*b**2*d*tan(c + d*x)) - 2*B*a*b**2/(2*a**4*d*tan(c + d*x) + 2*a**2*b**2*d*tan(c + d*x)) + 2*B*b*
*3*log(a/b + tan(c + d*x))*tan(c + d*x)/(2*a**4*d*tan(c + d*x) + 2*a**2*b**2*d*tan(c + d*x)) - 2*B*b**3*log(ta
n(c + d*x))*tan(c + d*x)/(2*a**4*d*tan(c + d*x) + 2*a**2*b**2*d*tan(c + d*x)), True))

Maxima [A] (verification not implemented)

none

Time = 0.29 (sec) , antiderivative size = 105, normalized size of antiderivative = 1.24 \[ \int \frac {\cot ^2(c+d x) (a B+b B \tan (c+d x))}{(a+b \tan (c+d x))^2} \, dx=\frac {\frac {2 \, B b^{3} \log \left (b \tan \left (d x + c\right ) + a\right )}{a^{4} + a^{2} b^{2}} - \frac {2 \, {\left (d x + c\right )} B a}{a^{2} + b^{2}} + \frac {B b \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{2} + b^{2}} - \frac {2 \, B b \log \left (\tan \left (d x + c\right )\right )}{a^{2}} - \frac {2 \, B}{a \tan \left (d x + c\right )}}{2 \, d} \]

[In]

integrate(cot(d*x+c)^2*(B*a+b*B*tan(d*x+c))/(a+b*tan(d*x+c))^2,x, algorithm="maxima")

[Out]

1/2*(2*B*b^3*log(b*tan(d*x + c) + a)/(a^4 + a^2*b^2) - 2*(d*x + c)*B*a/(a^2 + b^2) + B*b*log(tan(d*x + c)^2 +
1)/(a^2 + b^2) - 2*B*b*log(tan(d*x + c))/a^2 - 2*B/(a*tan(d*x + c)))/d

Giac [A] (verification not implemented)

none

Time = 0.53 (sec) , antiderivative size = 122, normalized size of antiderivative = 1.44 \[ \int \frac {\cot ^2(c+d x) (a B+b B \tan (c+d x))}{(a+b \tan (c+d x))^2} \, dx=\frac {\frac {2 \, B b^{4} \log \left ({\left | b \tan \left (d x + c\right ) + a \right |}\right )}{a^{4} b + a^{2} b^{3}} - \frac {2 \, {\left (d x + c\right )} B a}{a^{2} + b^{2}} + \frac {B b \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{2} + b^{2}} - \frac {2 \, B b \log \left ({\left | \tan \left (d x + c\right ) \right |}\right )}{a^{2}} + \frac {2 \, {\left (B b \tan \left (d x + c\right ) - B a\right )}}{a^{2} \tan \left (d x + c\right )}}{2 \, d} \]

[In]

integrate(cot(d*x+c)^2*(B*a+b*B*tan(d*x+c))/(a+b*tan(d*x+c))^2,x, algorithm="giac")

[Out]

1/2*(2*B*b^4*log(abs(b*tan(d*x + c) + a))/(a^4*b + a^2*b^3) - 2*(d*x + c)*B*a/(a^2 + b^2) + B*b*log(tan(d*x +
c)^2 + 1)/(a^2 + b^2) - 2*B*b*log(abs(tan(d*x + c)))/a^2 + 2*(B*b*tan(d*x + c) - B*a)/(a^2*tan(d*x + c)))/d

Mupad [B] (verification not implemented)

Time = 7.56 (sec) , antiderivative size = 113, normalized size of antiderivative = 1.33 \[ \int \frac {\cot ^2(c+d x) (a B+b B \tan (c+d x))}{(a+b \tan (c+d x))^2} \, dx=\frac {B\,\ln \left (\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )}{2\,d\,\left (b+a\,1{}\mathrm {i}\right )}-\frac {B\,\mathrm {cot}\left (c+d\,x\right )}{a\,d}-\frac {B\,b\,\ln \left (\mathrm {tan}\left (c+d\,x\right )\right )}{a^2\,d}+\frac {B\,b^3\,\ln \left (a+b\,\mathrm {tan}\left (c+d\,x\right )\right )}{a^2\,d\,\left (a^2+b^2\right )}+\frac {B\,\ln \left (\mathrm {tan}\left (c+d\,x\right )-\mathrm {i}\right )\,1{}\mathrm {i}}{2\,d\,\left (a+b\,1{}\mathrm {i}\right )} \]

[In]

int((cot(c + d*x)^2*(B*a + B*b*tan(c + d*x)))/(a + b*tan(c + d*x))^2,x)

[Out]

(B*log(tan(c + d*x) - 1i)*1i)/(2*d*(a + b*1i)) + (B*log(tan(c + d*x) + 1i))/(2*d*(a*1i + b)) - (B*cot(c + d*x)
)/(a*d) - (B*b*log(tan(c + d*x)))/(a^2*d) + (B*b^3*log(a + b*tan(c + d*x)))/(a^2*d*(a^2 + b^2))